package spring.cloud.tasks.common.status;

/**
 * 任务实例状态
 */
public class TaskInstanceInfoStatus {
    /**
     * 如果出现了状态值为空,为了保证程序正常,直接清理对应任务实例-任务实例阶段-分片信息。如果真的出现了这种情况则需要查明具体什么原因导致的。
     */
    public static final String status_value_is_null = "status_value_is_null";
    /**
     * 创建任务实例对象
     */
    public static final String create_instance_object = "create_instance_object";//创建内存对象
    /**
     * @$表示在ZK上面进行操作
     */
    public static final String $register_task_instance_info_success$ = "@register_task_instance_info_success";//待生成实例信息
    public static final String $register_task_instance_info_failure$ = "@register_task_instance_info_failure";
    public static final String $create_instance_task_item_info_success$ = "@create_instance_task_item_info_success";//生成实例信息成功
    public static final String $create_instance_task_item_info_failure$ = "@create_instance_task_item_info_failure";//生成实例信息失败
    //
    public static final String user_cancel = "user_cancel";//用户取消

    public static final String waiting_task_item_pre_assign_success = "waiting_task_item_pre_assign_success";//打上预调度标记，则需要真正的进行执行。
    //后面都是预分配后的状态 成功失败以及超时
    public static final String status_success = "success";
    public static final String status_fail = "fail";
    public static final String status_timeout = "timeout";
    //
    public static final String status_completed = "completed";//针对简单分片任务，是否都完成了
    public static final String status_stage_not_find = "stage_not_find";//阶段不存在

    public static boolean isTerminalState(String status) {
        return  /**预分配后可能的状态*/status_success.equals(status) || status_fail.equals(status) || status_timeout.equals(status) || status_stage_not_find.equals(status);//
    }
}
